package org.openkanban.client.ui.presenter;

import org.openkanban.client.ui.adminpanel.UserAccountPasswordForm;
import org.openkanban.shared.dto.StatusDto;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;

/**
 * Callback that handles update user account request
 */
public class UpdateUserAccountPasswordRequestCallback implements RequestCallback {

    private UserAccountPasswordForm view;

    public UpdateUserAccountPasswordRequestCallback(UserAccountPasswordForm view) {
	this.view = view;
    }

    @Override
    public void onResponseReceived(Request request, Response response) {
	StatusDto status = new StatusDto(response.getText());
	if (status.isCallSuccessfull()) {
	    view.showSuccessMessage();
	} else {
	    view.showFailureMessage();
	}
    }

    @Override
    public void onError(Request request, Throwable exception) {

    }

}
